<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script type="text/javascript">
      $(function() {

        $("#sortHead").headSort();
      });
      function confirmDelete() {
        return confirm("<s:message code='confirmDelete'/>");
      }
      function optSingle(opt) {
        if(Cms.checkeds("ids")==0) {
          alert("<s:message code='pleaseSelectRecord'/>");
          return false;
        }
        if(Cms.checkeds("ids")>1) {
          alert("<s:message code='pleaseSelectOne'/>");
          return false;
        }
        var id = $("input[name='ids']:checkbox:checked").val();
        location.href=$(opt+id).attr("href");
      }
      function optDelete(form) {
        if(Cms.checkeds("ids")==0) {
          alert("<s:message code='pleaseSelectRecord'/>");
          return false;
        }
        if(!confirmDelete()) {
          return false;
        }
        form.action='delete.do';
        form.submit();
        return true;
      }
      function  updatePriority(infoId) {
          if (infoId == '' || infoId == null) {
              return false;
          }
          var priority = $("#" + infoId).val();
          var r = new RegExp("^(\\d|[1-9]\\d|100)$");　　//0-100整数
          if (!r.test(priority)) {
              alert("请输入数字0~100（整数）！");
              return false;
          }
          var data = {};
          data.infoId = infoId;
          data.priority = priority;
          var url = CMSCP + '/core/gc/updatePriority.do';
          $.ajax({
              type: "POST",
              url: url,
              dataType: "json",
              data: data,
              async: false,
              success: function (msg) {
                  if (msg.msg == 'success') {
                      alert('修改成功！');
                  } else {
                      alert('参数错误，请刷新重试！');
                  }

              },
              error: function (msg) {
                  alert("系统异常！");
              }
          });
      }
    </script>
</head>
<body class="skin-blue content-body" id="load">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1><s:message code="gc"/> - <s:message code="list"/> <small>(<s:message code="totalElements" arguments="${pagedList.totalElements}"/>)</small></h1>
</div>
<div class="content">
    <div class="box box-primary">
        <div class="box-body table-responsive">
            <form class="form-inline ls-search" action="list.do" method="get">
                <div class="form-group">
                    <label>高层姓名</label>
                    <input class="form-control input-sm" type="text" name="search_CONTAIN_userName" value="${search_CONTAIN_userName[0]}"/>
                </div>
                <button class="btn btn-default btn-sm" type="submit"><s:message code="search"/></button>
            </form>
            <form id="batchForm" method="post">
                <tags:search_params/>
                <div class="btn-toolbar ls-btn-bar">
                    <div class="btn-group">
                        <shiro:hasPermission name="core:gc:create">
                            <button class="btn btn-default" type="button" onclick="location.href='create.do?${searchstring}';"><s:message code="create"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <shiro:hasPermission name="core:gc:delete">
                            <button class="btn btn-default" type="button" onclick="return optDelete(this.form);"><s:message code="delete"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <shiro:hasPermission name="core:gc:generation">
                            <button class="btn btn-default" type="button" onclick="$('#load').showLoading();location.href='generation.do';">生成</button>
                        </shiro:hasPermission>
                    </div>
                </div>
                <table id="pagedTable" class="table table-condensed table-bordered table-hover ls-tb">
                    <thead id="sortHead" pagesort="<c:out value='${page_sort[0]}' />" pagedir="${page_sort_dir[0]}" pageurl="list.do?page_sort={0}&page_sort_dir={1}&${searchstringnosort}">
                    <tr class="ls_table_th">
                        <th><input type="checkbox" onclick="Cms.check('ids',this.checked);"/></th>
                        <th width="140px;"><s:message code="operate"/></th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="id">ID</span></th>
                        <th>姓名</th>
                        <th>职位</th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="priority"><s:message code="info.priority"/></span><span style="color: red"><br/>(0-100整数，数值大，优先级高)</span></th>
                        <th>头像地址</th>
                        <th>个人简历地址</th>
                        <th>关联专题</th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="replacement">更新时间</span></th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="bean" varStatus="status" items="${pagedList.content}">
                        <tr<shiro:hasPermission name="core:gc:edit"> ondblclick="location.href=$('#edit_opt_${bean.id}').attr('href');"</shiro:hasPermission>>
                            <td><input type="checkbox" name="ids" value="${bean.id}"/></td>
                            <td align="center">
                                <shiro:hasPermission name="core:gc:edit">
                                    <a id="edit_opt_${bean.id}" href="edit.do?id=${bean.id}&position=${pagedList.number*pagedList.size+status.index}&${searchstring}" class="ls-opt"><s:message code="edit"/></a>
                                </shiro:hasPermission>
                                <shiro:hasPermission name="core:gc:delete">
                                    <a href="delete.do?ids=${bean.id}&${searchstring}" onclick="return confirmDelete();" class="ls-opt"><s:message code="delete"/></a>
                                </shiro:hasPermission>
                            </td>
                            <td align="center"><c:out value="${bean.id}"/></td>
                            <td align="center"><c:out value="${bean.userName}"/></td>
                            <td align="center"><c:out value="${bean.position}"/></td>
                            <td align="right" style="text-align: center"><f:text class="form-control input-sm" name="priority" id="${bean.id}" style="    width: 60px;    display: -webkit-inline-box;" maxlength="9" AUTOCOMPLETE="OFF" value="${bean.priority}"/>
                                <button class="btn btn-default" type="button" onclick="updatePriority(${bean.id})">保存</button>

                            </td>
                            <td align="center"><c:if test="${not empty bean.images}"><img src="${bean.images}" style="width: 242px;height: 131px" /></c:if></td>
                            <td align="center"><c:choose>
                                <c:when test="${bean.info.status eq 'A'}">
                                    <f:text class="form-control input-sm" style="    width: 230px;    display: -webkit-inline-box;"  value="http://192.168.81.70:8080${bean.info.sharedUrl}" />
                                </c:when>
                                <c:otherwise>
                                    <f:text class="form-control input-sm" style="    width: 230px;    display: -webkit-inline-box;"  value="http://cmsscgc.sctv.com${bean.info.preUrl}" />
                                </c:otherwise>
                            </c:choose></td>
                            <td align="center"><c:out value="${bean.special.title}"/></td>
                            <td align="center"><c:out value="${bean.createTime}"/></td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <c:if test="${fn:length(pagedList.content) le 0}">
                    <div class="ls-norecord"><s:message code="recordNotFound"/></div>
                </c:if>
            </form>
            <form action="list.do" method="get" class="ls-page">
                <tags:search_params excludePage="true"/>
                <tags:pagination pagedList="${pagedList}"/>
            </form>
        </div>
    </div>
</div>



</body>
</html>